<template>
  <div>
    <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleTabClick">
      <el-tab-pane v-for="(item, index) in tabList" :key="index" :label="item.label" :name="item.value"></el-tab-pane>
    </el-tabs>
   <el-scrollbar max-height="80vh">
      <div class="content" v-html="content"></div>
   </el-scrollbar>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import apiMod from '@/apiMod'

type Props = {
  nowRowData: any
}
const props = withDefaults(defineProps<Props>(), {})

const tabList = props.nowRowData.policyRelList || []
const activeName = ref('')
const content = ref('')
if (tabList.length > 0) {
  activeName.value = tabList[0].value
}
const getInitData = () => {
  if (!activeName.value) {
    return
  }
  apiMod.dpPolicyDocument_view(activeName.value).then((res) => {
    content.value = res.data?.policyContent
  })
}

const handleTabClick = () => {
  getInitData()
}
onMounted(() => {
  getInitData()
})

</script>

<style scoped></style>